﻿using System;
using SharpSqlAnalyzer.nodes;

namespace SharpSqlAnalyzer.stmt
{
	// Token: 0x0200008F RID: 143
	public class TCommonBlock : TCommonStoredProcedureSqlStatement
	{
		// Token: 0x060003C0 RID: 960 RVA: 0x002FA259 File Offset: 0x002F8459
		public TCommonBlock(EDbVendor dbvendor) : base(dbvendor)
		{
			this.sqlstatementtype = ESqlStatementType.sst_block_with_label;
		}

		// Token: 0x060003C1 RID: 961 RVA: 0x002FA26A File Offset: 0x002F846A
		internal override void buildsql()
		{
		}

		// Token: 0x060003C2 RID: 962 RVA: 0x002FA26C File Offset: 0x002F846C
		internal override void clear()
		{
		}

		// Token: 0x060003C3 RID: 963 RVA: 0x002FA26E File Offset: 0x002F846E
		internal override string getasprettytext()
		{
			return "";
		}

		// Token: 0x060003C4 RID: 964 RVA: 0x002FA275 File Offset: 0x002F8475
		internal virtual void iterate(TVisitorAbs pvisitor)
		{
		}

		// Token: 0x17000068 RID: 104
		// (get) Token: 0x060003C5 RID: 965 RVA: 0x002FA277 File Offset: 0x002F8477
		public override TObjectName LabelName
		{
			get
			{
				return this._labelName;
			}
		}

		// Token: 0x060003C6 RID: 966 RVA: 0x002FA280 File Offset: 0x002F8480
		public override int doParseStatement(TCustomSqlStatement psql)
		{
			TBlockSqlNode tblockSqlNode = (TBlockSqlNode)this.rootNode;
			base.doParseStatement(psql);
			this._labelName = tblockSqlNode.LabelName;
			this.EndLabelName = tblockSqlNode.EndLabelName;
			if (tblockSqlNode.DeclareStmts != null)
			{
				tblockSqlNode.DeclareStmts.doParse(this, ESqlClause.unknown);
				for (int i = 0; i < tblockSqlNode.DeclareStmts.size(); i++)
				{
					this.DeclareStatements.add(tblockSqlNode.DeclareStmts.getStatementSqlNode(i).Stmt);
				}
				for (int j = 0; j < tblockSqlNode.DeclareStmts.size(); j++)
				{
					this.TopStatement.SymbolTable.Push(new TSymbolTableItem(10, this, tblockSqlNode.DeclareStmts.getStatementSqlNode(j).Stmt));
				}
			}
			tblockSqlNode.Stmts.doParse(this, ESqlClause.unknown);
			for (int k = 0; k < tblockSqlNode.Stmts.size(); k++)
			{
				this.BodyStatements.add(tblockSqlNode.Stmts.getStatementSqlNode(k).Stmt);
			}
			if (tblockSqlNode.ExceptionClause != null)
			{
				tblockSqlNode.ExceptionClause.doParse(this, ESqlClause.unknown);
				this.ExceptionClause = tblockSqlNode.ExceptionClause;
			}
			if (tblockSqlNode.DeclareStmts != null)
			{
				for (int l = 0; l < tblockSqlNode.DeclareStmts.size(); l++)
				{
					this.TopStatement.SymbolTable.Pop();
				}
			}
			return 0;
		}

		// Token: 0x060003C7 RID: 967 RVA: 0x002FA3D3 File Offset: 0x002F85D3
		public override void accept(TParseTreeVisitor v)
		{
			v.preVisit(this);
			v.postVisit(this);
		}

		// Token: 0x060003C8 RID: 968 RVA: 0x002FA3E4 File Offset: 0x002F85E4
		public override void acceptChildren(TParseTreeVisitor v)
		{
			v.preVisit(this);
			if (this.DeclareStatements.size() > 0)
			{
				this.DeclareStatements.acceptChildren(v);
			}
			if (this.BodyStatements.size() > 0)
			{
				this.BodyStatements.acceptChildren(v);
			}
			v.postVisit(this);
		}

		// Token: 0x040010BD RID: 4285
		private TObjectName _labelName;
	}
}
